﻿using System;
using CARMSBusiness;

namespace CARMS.Admin
{
    [Function("Admin.MyProfile")]
    public partial class MyProfile : PageBase
    { 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                var userInformationData = SecurityBusiness.GetUserByID(CurrentLoginUser.UserID);
                if (userInformationData != null)
                {
                    fpUserInfo.DataSource = userInformationData;
                    fpUserInfo.DataBind();

                }
            }
        }

        protected void btnSaveChange_Click(object sender, EventArgs e)
        {
            var userInformationData = SecurityBusiness.GetUserByID(CurrentLoginUser.UserID);
            fpUserInfo.ExtractValues(userInformationData, false);
            if (SecurityBusiness.SaveUser(userInformationData))
            {
                Alert("The user information have been successfully saved!");
            }
            else
            {
                Alert("Save user information changes failed!");
            }

        }
    }


}